
import { withPixiApp, Container } from '@inlet/react-pixi'
import React from 'react'
import { connect } from 'react-redux'
import { projectLabelView as projectDuck } from 'ducks'
import PropTypes from 'prop-types'
import { Polygon } from '../brushes'

const EditPolygonView = ({
  actionPaintPoint,
  isEditPolygonHole,
  label,
  color,
}) => {
  return (
    <Container>
      <Polygon
        label={label}
        color={color}
        edit
        hole={isEditPolygonHole}
        click={actionPaintPoint}
      />
    </Container>
  )
}

EditPolygonView.propTypes = {
  actionPaintPoint: PropTypes.func.isRequired,
  isEditPolygonHole: PropTypes.bool.isRequired,
  label: PropTypes.object.isRequired,
  color: PropTypes.string.isRequired,
}

const mapStateToProps = state => ({
  isEditPolygonHole: projectDuck.selectors.isEditPolygonHole(state),
})

const mapDispatchToProps = {
  actionPaintPoint: projectDuck.creators.actionPaintPoint,
}


export default withPixiApp(connect(mapStateToProps, mapDispatchToProps)(EditPolygonView))
